﻿using Orchard.ContentManagement.Drivers;
using Orchard.Environment.Extensions;
using OrchardHUN.QnA.Models;

namespace OrchardHUN.QnA.Drivers
{
    [OrchardFeature("OrchardHUN.QnA")]
    public class QnADiscussionPoolPartDriver : ContentPartDriver<QnADiscussionPoolPart>
    {
        protected override string Prefix
        {
            get { return "QnADiscussionPool"; }
        }

        protected override DriverResult Display(QnADiscussionPoolPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Parts_NewDiscussionLink",
                () => shapeHelper.Parts_NewDiscussionLink(
                            DiscussionPoolId: part.ContentItem.Id));
        }

        // GET
        protected override DriverResult Editor(QnADiscussionPoolPart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_HideContainerItemContentTypeSelector_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts/HideContainerItemContentTypeSelector",
                    Model: part,
                    Prefix: Prefix));
        }

        //// POST
        //protected override DriverResult Editor(QnADiscussionPoolPart part, IUpdateModel updater, dynamic shapeHelper)
        //{
        //    //updater.TryUpdateModel(part, Prefix, null, null);
        //    return Editor(part, shapeHelper);
        //}
    }
}